local arm = fk.CreateSkill{
  name = "arm",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["arm"] = "武装",
  [":arm"] = "锁定技，每回合结束或你回复体力时，若有已废除的装备栏，摸一张牌并恢复一个装备栏，否则失去1点体力。",
  ["RideSlot"] = "坐骑栏",
  ["#arm"] = "选择恢复一个装备栏并摸一张牌。",

  ["$arm"] = "枪管冷却。",
}

arm:addEffect(fk.TurnEnd, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(arm.name) and
      target == player and
      table.find(player.sealedSlots, function(slot_name)
        return slot_name ~= Player.JudgeSlot
      end) then
      return true
    end
  end,

  on_use = function(self, event, target, player, data)
  local room = player.room
  local all_slots = {"WeaponSlot", "ArmorSlot", "DefensiveRideSlot", "OffensiveRideSlot", "TreasureSlot"}
  local choices = {}
  for _, equip_slot in ipairs(all_slots) do
    if table.contains(player.sealedSlots, equip_slot) then
      table.insert(choices, equip_slot)
    end
  end
  if #choices > 0 then
    local choice = room:askToChoice(player, {
      choices = choices,
      skill_name = arm.name,
      prompt = "#arm",
    })
    room:resumePlayerArea(player, {choice})
    player:drawCards(1, arm.name)
  end
end
})

arm:addEffect(fk.TurnEnd, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(arm.name) and
      target == player and
      not table.find(player.sealedSlots, function(slot_name)
        return slot_name ~= Player.JudgeSlot
      end) then
      return true
    end
  end,

  on_use = function(self, event, target, player, data)
  player.room:loseHp(player, 1, arm.name)
end
})

arm:addEffect(fk.PreHpRecover, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(arm.name) and
      target == player and
      table.find(player.sealedSlots, function(slot_name)
        return slot_name ~= Player.JudgeSlot
      end) then
      return true
    end
  end,

  on_use = function(self, event, target, player, data)
  local room = player.room
  local all_slots = {"WeaponSlot", "ArmorSlot", "DefensiveRideSlot", "OffensiveRideSlot", "TreasureSlot"}
  local choices = {}
  for _, equip_slot in ipairs(all_slots) do
    if table.contains(player.sealedSlots, equip_slot) then
      table.insert(choices, equip_slot)
    end
  end
  if #choices > 0 then
    local choice = room:askToChoice(player, {
      choices = choices,
      skill_name = arm.name,
      prompt = "#arm",
    })
    room:resumePlayerArea(player, {choice})
    player:drawCards(1, arm.name)
  end
end
})

arm:addEffect(fk.PreHpRecover, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(arm.name) and
      target == player and
      not table.find(player.sealedSlots, function(slot_name)
        return slot_name ~= Player.JudgeSlot
      end) then
      return true
    end
  end,

  on_use = function(self, event, target, player, data)
  player.room:loseHp(player, 1, arm.name)
end
})

return arm